import os

class Config:
    # 基础路径配置
    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    RESOURCES_DIR = os.path.join(BASE_DIR, 'resources')
    LOGS_DIR = os.path.join(BASE_DIR, 'logs')
    
    # AT&T解锁页面配置
    ATT_UNLOCK_URL = "https://www.att.com/deviceunlock/"
    COOKIE_BUTTON_SELECTOR = "button.btn-primary"
    BRAND_DROPDOWN_SELECTOR = "div.select-container"
    BRAND_SELECT_SELECTOR = "select[aria-label='Select brand']"
    
    # 反馈弹窗配置
    FEEDBACK_BUTTON = "button.fsrButton"  # 反馈按钮
    FEEDBACK_DIALOG_SELECTOR = "div.uws-modal__body"  # 反馈弹窗
    FEEDBACK_CLOSE_BUTTON = "button.uws-modal__close"  # 关闭按钮
    FEEDBACK_NO_THANKS = "button.uws-invite__decline-button"  # No thanks按钮

    # 日志配置
    LOG_LEVEL = 'INFO'
    LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s'
    LOG_FILE = os.path.join(LOGS_DIR, 'att_unlock.log')
    LOG_ENCODING = 'utf-8'

    # 创建必要的目录
    @classmethod
    def create_directories(cls):
        """创建必要的目录结构"""
        os.makedirs(cls.RESOURCES_DIR, exist_ok=True)
        os.makedirs(cls.LOGS_DIR, exist_ok=True)

    # 初始化配置
    @classmethod
    def init(cls):
        """初始化配置"""
        cls.create_directories()
        
        # 配置日志
        import logging
        logging.basicConfig(
            level=getattr(logging, cls.LOG_LEVEL),
            format=cls.LOG_FORMAT,
            handlers=[
                logging.FileHandler(cls.LOG_FILE, encoding=cls.LOG_ENCODING),
                logging.StreamHandler()
            ]
        ) 